#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

typedef int BTDatatype;


typedef struct BinaryTreeNode
{
	BTDatatype data;
	struct BinaryTreeNode* left;
	struct BinaryTreeNode* right;

}BTNode;
BTNode* BuyBTNode(BTDatatype x)
{
	BTNode* newnode = (BTNode*)malloc(sizeof(BTNode));
	if (newnode == NULL)
	{
		perror("malloc fail");
		exit(-1);
	}
	newnode->data = x;
	newnode->left = NULL;
	newnode->right = NULL;

	return newnode;

}
bool _issymmetry(struct BinaryTreeNode* root1, struct BinaryTreeNode* root2)
{
	if (root1 == NULL && root2 == NULL)
		return true;
	if (root1 == NULL || root2 == NULL)
		return false;
	if (root1->data != root2->data)
		return false;
	return _issymmetry(root1->left, root2->right)
		&& _issymmetry(root1->right, root2->left);
}
bool issymmetry(struct BinaryTreeNode* root)
{
	return !root || _issymmetry(root->left, root->right);
}


int main()
{
	BTNode* n1 = BuyBTNode(1);
	BTNode* n2 = BuyBTNode(2);
	BTNode* n3 = BuyBTNode(2);
	BTNode* n4 = BuyBTNode(2);
	BTNode* n5 = BuyBTNode(2);
	BTNode* n6 = BuyBTNode(2);
	BTNode* n7 = BuyBTNode(2);
	n1->left = n2;
	n1->right = n4;
	n2->left = n3;
	n4->left = n5;
	n4->right = n6;
	n2->right = n7;
	int ret = issymmetry(n1);
	printf("%d ", ret);
	return 0;
}
